package com.weave.test;

import com.weave.model.GameModel;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.*;


public class GameModelTest {
    private GameModel model;

    @BeforeEach
    public void setup() {
        model = new GameModel();
        model.setValidationFlag(true);
    }

    @Test
    public void testValidTransition() {
        model.processInput("AALS");
        model.processInput("ABLS");
        assertEquals(2, model.getSteps().size()-1);
    }

    @Test
    public void testInvalidLengthWithMessage() {
        IllegalArgumentException exception = assertThrows(
                IllegalArgumentException.class,
                () -> model.processInput("LONGWORD")
        );

        // 验证异常消息
        assertTrue(exception.getMessage().contains("It must be four letters"));
    }

    @Test
    public void testWinCondition() {
        model.processInput("AALS");
        model.processInput("ABLS");
        assertTrue(model.isGameWon());
    }
}